import { ResPage, Custom } from "@/api/interface/index";
import { CUSTOM } from "@/api/config/servicePort";
import http from "@/api";

// 获取客户列表
export const getCustomList = (params: Custom.ResCustomList) => {
  return http.post<ResPage<Custom.ResCustomList>>(CUSTOM + `/customer/page`, params);
};

// 新增客户
export const addCustom = (params: any) => {
  return http.post(CUSTOM + `/customer/create`, params);
};

// 批量添加客户
export const BatchAddCustom = (params: FormData) => {
  return http.post(CUSTOM + `/custom/import`, params);
};

// 编辑客户
export const editCustom = (params: any) => {
  return http.post(CUSTOM + `/customer/update`, params);
};

// 删除客户
export const deleteCustom = (params: { customerId: number }) => {
  return http.post(CUSTOM + `/customer/delete`, params);
};

// 查询客户订单
export const searchCustomOrder = (params: { customId: string[] }) => {
  return http.post(CUSTOM + `/custom/searchOrder`, params);
};

// 切换客户状态
export const changeCustomStatus = (params: { customId: string; status: number }) => {
  return http.post(CUSTOM + `/custom/change`, params);
};

// 导出客户数据
export const exportCustomInfo = (params: Custom.ResCustomList) => {
  return http.download(CUSTOM + `/custom/export`, params);
};

// 获取订单列表
export const getOrderList = (params: Custom.ResOrderList) => {
  return http.post<ResPage<Custom.ResOrderList>>(CUSTOM + `/order/page`, params);
};

// 获取全部订单统计信息
export const orderStatistics = () => {
  return http.get<{ allOrderNumber: number; todayOrderNumber: number; todaySale: number }>(CUSTOM + `/order/orderStatistics`);
};

//获得畅销商品
export const getTopSale = () => {
  return http.get<Custom.ReqTopGoods[]>(CUSTOM + `/order/getTopGoods`);
};

// 新增订单
export const addOrder = (params: any) => {
  return http.post(CUSTOM + `/order/place`, params);
};

// 批量添加订单
export const BatchAddOrder = (params: FormData) => {
  return http.post(CUSTOM + `/order/import`, params);
};

// 导出订单数据
export const exportOrderInfo = (params: Custom.ResOrderList) => {
  return http.download(CUSTOM + `/order/export`, params);
};

// 查看
export const showOrder = (params: { orderId: string }) => {
  return http.post(CUSTOM + `/order/cancel`, params);
};

// 换货
export const exchangeOrder = (params: { orderId: string }) => {
  return http.post(CUSTOM + `/order/exchangeOrder`, params);
};

//退货;
export const returnOrder = (params: { orderId: string }) => {
  return http.post(CUSTOM + `/order/returnOrder`, params);
};
